/**
 * Created by modh on 2019-10-28.
 */

const Sequelize = require('sequelize');

/**
 * host：数据库地址
 * max：连接池最大连接数量
 * min：连接池最小连接数量
 * idle：每个线程最长等待时间
 * @type {Sequelize}
 */

const sequelize = new Sequelize($config._dc.base.db, $config._dc.base.name, $config._dc.base.pwd, $config._dc.param);
/**
 * 测试数据库连接状态
 */
sequelize.authenticate().then(() => {
    console.log('\x1B[35mConnection has been established successfully.\x1B[0m');
}).catch(err => {
    console.error(`\x1B[35mUnable to connect to the database: ${err}\x1B[0m`);
});

module.exports = sequelize;
